/*
 * 学科
 */

import { createAPI } from '@/utils/request'

// 学科列表
export const list = data => createAPI('/subjects', 'get', data)
  .then(res => ({
    ...res.data,
    items: res.data.items.map(d => ({
      ...d,
      isFrontDisplay: d.isFrontDisplay ? '是' : '否'
    }))
  }))
  .catch(() => {})

// 学科简单列表
export const simple = data => createAPI('/subjects/simple', 'get', data)
  .then(res => res.data)
  .catch(() => [])

// 学科详情
export const detail = data => createAPI(`/subjects/${data.id}`, 'get', data)

// 学科添加
export const add = data => createAPI('/subjects', 'post', data)

// 学科修改
export const update = data => createAPI(`/subjects/${data.id}`, 'put', data)

// 学科删除
export const remove = data => createAPI(`/subjects/${data.id}`, 'delete', data)
